package com.itheima.jstl;

import com.itheima.domain.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@WebServlet("/demo6")
public class ServletDemo6 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("demo6.....");
        List<User> users = new ArrayList<>();
        User user1 = new User("张山1", 22, new Date());
        User user2 = new User("张山2", 23, new Date());
        User user3 = new User("张山3", 24, new Date());
        users.add(user1);
        users.add(user2);
        users.add(user3);
        req.setAttribute("users",users);
        req.getRequestDispatcher("/jstl1.jsp").forward(req,resp);

    }
}
